import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/controller/knowledgeword.dart';
import 'package:ichinesereader/models/knowledgeword/knowledgeWord.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:flutter_svg/flutter_svg.dart';

// ignore: must_be_immutable
class FolderCard extends StatelessWidget {
  FolderCard(this.flashcard);

  KnowledgeWord flashcard;
  KnowledgeWordsController _knowledgeWordsController = Get.find();

  @override
  Widget build(BuildContext context) {
    Log.debug('build Folder widget');

    var heading = flashcard.text != null ? flashcard.text.toString() : '';
    var supportingText = '';
    if (flashcard.definition != null) {
      supportingText = flashcard.definition.toString();
      supportingText = supportingText.replaceAll('[', '').replaceAll(']', '');
    }
    var folderId =
        flashcard.folderId != null ? flashcard.folderId.toString() : '';

    return Scaffold(
      body: Card(
          color: Colors.white,
          elevation: 12.0,
          child: Column(
            children: [
              ListTile(
                  title: Text(
                    heading,
                    textAlign: TextAlign.center,
                    style: Theme.of(context).textTheme.bodyLarge,
                  ),
                  onTap: () {
                    Log.debug('Folder tapped$folderId');
                    // _controller.createFolderKnowledgeWord();
                    if (folderId != '') {
                      _knowledgeWordsController.folderdir.add(folderId);
                      _knowledgeWordsController.folderDirName.add(heading);
                      _knowledgeWordsController.getFolders();
                    }
                  }),
              GestureDetector(
                onTap: () {
                  if (folderId != '') {
                    _knowledgeWordsController.folderdir.add(folderId);
                    _knowledgeWordsController.folderDirName.add(heading);
                    _knowledgeWordsController.getFolders();
                  }
                },
                child: Container(
                  child: SvgPicture.asset('assets/images/folder.svg',
                      height: 60, width: 100),
                ),
              ),
            ],
            // })
          )),
    );
  }
}
